﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using nTribeHR.Utilities;

namespace nTribeHRTests
{
    [TestClass]
    public class UtilitiesTests : BaseTribeHRUnitTest
    {
        [TestMethod]
        public void DoesDisposibleStopwatchWork()
        {
            DisposableStopwatch sw;
            using (sw = DisposableStopwatch.StartNew())
            {
                System.Threading.Thread.Sleep(1000);
            }
            Console.WriteLine(sw);
            Assert.IsTrue(sw.ElapsedMilliseconds > 990);
        }

        [TestMethod]
        public void CanStopDisposibleStopwatchBeforeEndOfUsingBlock()
        {
            DisposableStopwatch sw;
            using ( sw = DisposableStopwatch.StartNew("Stop before end of using block"))
            {
                System.Threading.Thread.Sleep(500);
                sw.Stop();
                System.Threading.Thread.Sleep(1000);
            }
            Console.WriteLine(sw);
            Assert.IsTrue(sw.ElapsedMilliseconds < 990);
        }

    }
}
